let arr = [5, 6, 7, 8, 1, 2, 3];
let result = arr.reduceRight((preValue, currentValue) => {
  return preValue + currentValue;
});
console.log(result); //32
console.log(arr);

result = arr.reduceRight((preValue, currentValue) => {
  return preValue - currentValue;
});
console.log(result); //-22

let arr1 = [
  { name: 'zg', age: 18 },
  { name: 'kobe', age: 35 },
  { name: 'lucy', age: 22 },
];
result = arr1.reduceRight((preValue, currentValue) => {
  return {
    name: preValue.name + currentValue.name,
    age: preValue.age + currentValue.age
  };
});
console.log(result); // {name: 'zgkobelucy', age: 75}
